<?php
$contactmail = 'quangthien.cse10@gmail.com';
$servermail = 'no-reply@abc.vn';

function mail_utf8($from, $to, $subject = '(No subject)', $message = '') 
{
	$headers = "From: $from\n";
	$headers .= "Reply-To: $from\n";
	$headers .= "Return-Path: $from\n";
	$headers .= "MIME-Version: 1.0\n";
	$headers .= "Content-type: text/plain; charset=UTF-8\n";
	/*
	echo "<pre>";
	echo "from:[$from]\n";
	echo "to:[$to]\n";
	echo "subject:[$subject]\n";
	echo "header:[$headers]\n";
	echo "message:[$message]\n";
	echo "</pre>";
	*/
  	mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $headers);
}
 
?>

<?php
	if (isset($_POST["email"]))
	{
		$name = $_POST["name"];
		$address = $_POST["address"];
		$phone = $_POST["phone"];
		$recipient = $contactmail;
		$from = $servermail;
		$customermail = $_POST['email'];

		if (isset($_POST["copy"]))
			$recipient .= ",$customermail";
		
		$subject = "[Liên Hệ]$customermail";
		$body = "Họ và Tên: $name\nĐịa chỉ: $address\nĐiện thoại: $phone\nEmail: $customermail\n";
		$body .= "-------------Nội dung-------------\n";
		$body .= $_POST["body"];
		mail_utf8($from, $recipient, $subject, $body);
	}

	header('Location: contact.php');
	
?>